using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DotNetNuke;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
using DotNetNuke.Entities.Users;

namespace Jfc007.WebLib
{
    public partial class DisplayBinaryData : PortalModuleBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            string fileIdTmp = this.Request.QueryString["FileId"];

            if (!String.IsNullOrEmpty(fileIdTmp))
            {
                DocumentsController objWebLibs = new DocumentsController();

                //get the content from the WebLib table
                Guid fileId = new Guid(fileIdTmp);
                DocumentInfo docInfo = objWebLibs.GetDocument(fileId);
                // if (docInfo.Share)
                //{
                Response.Clear();
                Response.ClearHeaders();
                Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + Convert.ToString(docInfo.FileGuid) + docInfo.Extension + "\"");
                Response.AppendHeader("cache-control", "must-revalidate");
                this.Page.Visible = false;
                Response.ContentType = docInfo.ContentType;
                Response.BinaryWrite(docInfo.Content);
                TextBox1.Visible = false;

                /*}
                else
                {


                }*/

                /*
                 * Thanks in advance..
     here my code is like..

    ResultSet rs=st.executeQuery(SqlQuery);
            System.out.println("PDFServlet.java: after execution of query");
            rs.next();    
        
            String fileName="logo_large.gif";        

            response.setContentType("image/gif");
            response.setHeader("Content-Disposition","attachment; filename=\""+fileName+"\"");
            response.setHeader("cache-control", "must-revalidate");


            ostr = response.getOutputStream();

            Blob bl = rs.getBlob("invoice_blob");
            buff = bl.getBytes(1, (int)bl.length());
            ostr.write(buff);
                    ostr.flush();
    */
            }

        }
    }
}